package org.hd.source.controller;

import org.hd.source.dto.Result;
import org.hd.source.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("tag")
public class TagController {

    @Autowired
    private TagService tagService;

    @GetMapping("/list")
    public Result list(Integer status){
        return Result.SUCCESS().setData("list", tagService.list(status));
    }

    @GetMapping("/add")
    public Result add(String name){
        tagService.add(name);
        return Result.SUCCESS();
    }

    @GetMapping("/update")
    public Result update(String id, String name){
        tagService.update(id, name);
        return Result.SUCCESS();
    }

    @GetMapping("/delete")
    public Result delete(String id){
        tagService.delete(id);
        return Result.SUCCESS();
    }

    @GetMapping("/updateStatus")
    public Result updateStatus(String id, Integer status){
        tagService.updateStatus(id, status);
        return Result.SUCCESS();
    }
}
